using HKB.Common;
using System;
using System.Data;
using System.Web;
namespace HKB.Web
{
	public class Shop_FShopClass
	{
		private Conn conn;
		private Pagination _pageHand = null;
		protected Pagination pageHand
		{
			get
			{
				Pagination pageHand;
				if (this._pageHand == null)
				{
					this._pageHand = new Pagination();
					this._pageHand.SQL_CloseTablePre = false;
					this._pageHand.P_Object = "";
					pageHand = this._pageHand;
				}
				else
				{
					pageHand = this._pageHand;
				}
				return pageHand;
			}
		}
		public Shop_FShopClass(Conn _conn)
		{
			this.conn = _conn;
		}
		public Shop_FShopClass()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public DataTable GetAllFShopClass(int indexpage, int maxperpage, string wherestr, string orderbystr)
		{
			return this.pageHand.GetDataTable("HLShop_FShopClass", indexpage, maxperpage, "FShopClassID", wherestr, orderbystr, this.conn, null);
		}
		public string GetPagePAnel(string linkhead)
		{
			this.pageHand.P_LinkHead = linkhead;
			return this.pageHand.ShowPagePanel();
		}
		public DataTable GetFShopClassByFShopClassID(int F_ShopClassID)
		{
			return this.conn.GetDataTable("SELECT * FROM HLShop_FShopClass Where F_ShopClassID=" + F_ShopClassID);
		}
		public DataTable GetFShopClassByUserID(int UserID)
		{
			return this.conn.GetDataTable("SELECT * FROM HLShop_FShopClass Where UserID=" + UserID);
		}
		public bool DeleteFShopClass(int F_ShopClassID)
		{
			this.conn.BeginTransaction();
			bool result;
			try
			{
				this.conn.ExecuteTransaction("DELETE HLShop_FShopClass Where F_ShopClassID=" + F_ShopClassID);
				this.conn.ExecuteTransaction("UPdate HLShop_MYFAVOURITE SET F_ShopClassID =-1 WHERE  F_ShopClassID=" + F_ShopClassID);
			}
			catch
			{
				this.conn.Rollback();
				result = false;
				return result;
			}
			this.conn.Commit();
			result = true;
			return result;
		}
		public void UpdateFShopClass(string F_ShopClassName, string F_ShopClassRemark, int F_ShopClassID)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@F_ShopClassName", DbType.String, F_ShopClassName),
				this.conn.CreateParameter("@F_ShopClassRemark", DbType.String, F_ShopClassRemark)
			};
			this.conn.Execute("UPDATE HLShop_FShopClass Set F_ShopClassName=@F_ShopClassName ,F_ShopClassRemark=@F_ShopClassRemark where F_ShopClassID=" + F_ShopClassID, parameters);
		}
		public void InsertFShopClass(string F_ShopClassName, int UserID, string F_ShopClassRemark)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@F_ShopClassName", DbType.String, F_ShopClassName),
				this.conn.CreateParameter("@F_ShopClassRemark", DbType.String, F_ShopClassRemark)
			};
			this.conn.Execute("INSERT INTO [HLShop_FShopClass]( [F_ShopClassName], [UserID], [F_ShopClassRemark]) VALUES (  @F_ShopClassName, " + UserID + ", @F_ShopClassRemark)", parameters);
		}
	}
}
